import { forBindEventThis } from '../../../../direct/Func/eventBind';
import { event_check_operate } from '../../../Event/Func/event_check/Classes/cla_event_check_operate';
import { event_dispatch__load_info } from '../DataDefine/sourceData';
import { select_empty_dataMana } from './cla_select_empty_dataMana';
// eslint-disable-next-line no-unused-vars
import { select_empty_defEvent } from './cla_select_empty_defEvent';

const select_empty_operateTag = 'select_empty_operate';

/**
 * 事件 检测
 */
const event_check_func = new event_check_operate();

class select_empty_operate extends select_empty_dataMana {
  get [Symbol.toStringTag]() {
    return select_empty_operateTag;
  }

  constructor(props) {
    super(props);

    forBindEventThis(this);

    this.eventM.addEventListen(
      this.select_empty_border_dom,
      'click',
      this.eventBind.select_empty_border_dom_click
    );

    // 给 border 上 加载 一个 自定义 事件 用于 传输 选中信息
    this.eventM.addEventListen(
      this.select_empty_border_dom,
      event_dispatch__load_info,
      this.eventBind.select_empty_border_dom_click
    );

    this.eventM.addEventListen(
      this.focusDisplay_dom,
      'click',
      this.eventBind.focusDisplay_white_space_click
    );
  }

  /**
   * 选择器 元素点击 展开选择 操作
   * @param {MouseEvent} event
   */
  select_empty_border_dom_click(event) {
    if (!event_check_func.cur_event(event).left_click().checked_result) {
      return;
    }

    this.open_focusDisplay_func();
  }

  /**
   * 自定义 事件 处理
   * 确认 当前选中的 元素
   * 完成 选择 操作
   * @param {select_empty_defEvent} defEvent
   */
  define_operate__load_info(defEvent) {
    let selected_items_id_arr = defEvent.selected_items_id_arr;
    this.load_selected_items_cur(selected_items_id_arr);

    this.certain_focusDisplay_func();
  }

  /**
   * 焦点元素 空白处 点击 取消 当前 操作
   * @param {MouseEvent} event
   */
  focusDisplay_white_space_click(event) {
    if (!event_check_func.cur_event(event).is_itself().checked_result) {
      return;
    }

    this.cancel_focusDisplay_func();
  }
}

export { select_empty_operate };
